# 给定一个二叉树，找出其最大深度。

# 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。

# 说明: 叶子节点是指没有子节点的节点。

# 示例：
# 给定二叉树 [3,9,20,null,null,15,7]，

# Definition for a binary tree node.


from tree_node import TreeNode
class Solution:
    def maxDepth(self, root: TreeNode) -> int:
        return self.get_depth(root, 1)

    def get_depth(self, root, depth):
        if not root:
            return 0
        left_depth = depth
        right_depth = depth
        print("root=", root)
        if root.left:
            left_depth = self.get_depth(root.left, depth+1)

        if root.right:
            right_depth = self.get_depth(root.right, depth+1)

        return max(left_depth, right_depth)


if __name__ == "__main__":
    a = TreeNode(3)
    b = TreeNode(9)
    c = TreeNode(20)
    d = TreeNode(15)
    e = TreeNode(7)
    f = TreeNode(8)

    a.left = b
    a.right = c
    c.left = d
    c.right = e
    e.right = f

    print(Solution().maxDepth(a))
